<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

</head>
<body>
<div style="background-color: #2ca02c">
    @if(count($errors)>0)
        @if(is_object($errors))
            @foreach($errors->all() as $error)
                <p>{{$error }}</p>
            @endforeach
        @else
            {{$errors}}
        @endif

    @endif
</div>
    <div style="text-align: center">
        <h1>网站配置管理</h1>
</div>


    <div style="padding-left: 100px;padding-bottom: 20px">
        <h2>快捷导航</h2>
        <a href="{{url('Admin/config/create')}}">添加</a>
        <a href="{{url('Admin/config')}}">更新</a>
    </div>
<form method="post" action="{{url('Admin/config/change')}}">

{{csrf_field()}}

    <table border="1px" width="60%"style="padding-left: 20px;color: red">
        <tr>
            <th width="5%">排序</th>
            <th width="5%">ID</th>
            <th width="5%">标题</th>
            <th width="5%">名称</th>
            <th width="5%">内容</th>
            <th width="5%">类型</th>
            <th width="5%">类型值</th>
            <th width="5%">说明</th>
            <th width="5%">操作</th>


        </tr>

        @foreach($confresoult as $y)
            <tr>
                <td>
                    <input type="text" onchange="order(this,{{$y->conf_id}}) " name="order[]" value="{{$y->conf_order}}"
                    style="margin-left: 20px;width: 50px;height: 20px"
                    />

                </td>

                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{$y->conf_id}}</td>

                <td>{{$y->conf_title}}</td>
                <td>{{$y->conf_name }}</td>
                <td>
                    <input type="hidden" value="{{$y->conf_id}}" name="conf_id[]"/>

                {!! $y->html !!}</td>
               <td>{{$y->field_type}}</td>
                <td>{{$y->field_value }}</td>
                <td>{{$y->conf_tips }}</td>



                <td>&nbsp;<a href="{{url('Admin/config/'.$y->conf_id.'/edit')}}">修改</a>&nbsp;&nbsp;
                    <a href="javascript::" onclick="artdel({{$y->conf_id}})">删除</a></td>
            </tr>


        @endforeach
    </table>
  <div class="btn_group">
      <input type="submit" value="提交"/>
      <input type="button" class="back" value="返回"/>
  </div>
</form>
   {{-- <div id="fen">
        {{$confresoult->links()}}
    </div>--}}
<script type="text/javascript" src="{{asset('resources/views/Admin/js/jquery-3.1.1.min.js')}}">
</script>
<script type="text/javascript" src="{{asset('resources/views/org/layer/layer.js')}}">
</script>

<script>
    function order(obj,conf_id ){
        var conforder=$(obj).val();
        $.post("{{url('Admin/config/order')}}",{'_token':'{{csrf_token()}}','conforder':conforder,'conf_id':conf_id},function (date) {

            if (date.status==1){
               /* location.href=location.href;*/
                layer.alert(date.msg, {icon: 6});
            }else {
            layer.msg(date.msg, {icon: 5});
        }
        });
    }

    function artdel(conf_id){
        layer.confirm('你确定删除这篇文章吗？', {
            btn: ['是的','取消']
        }, function(){
            $.post("{{url('Admin/config/')}}/"+conf_id,{'_method':'delete','_token':'{{csrf_token()}}'},function (update) {
                     if(update.status==1){
                   location.href=location.href;
                         layer.alert(update.msg, {icon: 6});
                     }else {
                         layer.msg(update.msg, {icon: 5});
                     }
            });


        }, function(){

        });
    }
</script>
</body>
</html>